home *** CD-ROM | disk | FTP | other *** search
- Path: news.Stanford.EDU!usenet
- From: Ramana Reddy Kurri <kurri@leland.Stanford.EDU>
- Newsgroups: comp.lang.c++
- Subject: Re: OOPS! - Re: How to delete array of pointers?
- Date: 12 Feb 1996 01:49:54 GMT
- Organization: Stanford University
- Message-ID: <4fm6c2$an8@nntp.Stanford.EDU>
- References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> <4fi8rd$738@reader2.ix.netcom.com> <4fkv8j$kb@cloner3.netcom.com>
- NNTP-Posting-Host: elaine11.stanford.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.12 (X11; I; SunOS 4.1.4 sun4m)
- X-URL: news:4fkv8j$kb@cloner3.netcom.com
-
- This is one way to return memory to heap for a two dimensional array.
-
- int **arr;
- arr = new int*[10];
-
- for(int i=0; i<10; i++)
- arr[i] = new int[10];
-
- // Do whatever you want....
-
- first delete the memory you have allocated to arr[i] and
- then deallocate the memory for arr
-
- for(int j=0; j<10; j++)
- delete [] arr[j];
-
- delete [] arr;
-
- --Ramana
-
-